﻿
Partial Class store_UCManual
    Inherits System.Web.UI.UserControl

    Public Sub Display(p As CProduct)
        lnkName.Text = p.ProductName 'AndPrice
        lnkName.NavigateUrl = CSitemap.Decide(p)
        lnkThumb.NavigateUrl = CSitemap.Decide(p)

        Dim pp As CProduct = p.CSPaperback
        If Not IsNothing(pp) Then
            lnkThumb.Visible = True
            lnkThumb.ImageUrl = CSitemap.ProductThumb(pp)
        ElseIf p.HasImage Then
            lnkThumb.Visible = True
            lnkThumb.ImageUrl = CSitemap.ProductThumb(p)
        Else
            divBorder.Visible = False
        End If

        lnkOrderNow.NavigateUrl = CSitemap.Decide(p) & "#notes"

        litDescription.Text = p.Description_Br

        If p.ProductCSBookIdOrParent > 0 Then
            lnkPaperback.Visible = True
            lnkPaperback.NavigateUrl = CSitemap.External_CreateSpace(p.ProductCSBookIdOrParent)

        End If
        If Not String.IsNullOrEmpty(p.ProductVimeoChannelIdOrParent) Then
            lnkVimeo.Visible = True
            lnkVimeo.NavigateUrl = p.VideoUrl_VimeoChannel
        End If
        If Not String.IsNullOrEmpty(p.ProductYouTubePlaylistIdOrParent) Then
            lnkYouTube.Visible = True
            lnkYouTube.NavigateUrl = p.VideoUrl_YouTubePlaylist
        End If
        If Not String.IsNullOrEmpty(p.ProductAmazonIdOrParent) Then
            lnkKindle.Visible = True
            lnkKindle.NavigateUrl = CSitemap.External_Amazon(p.ProductAmazonIdOrParent)
        End If


        lnkOrderNow.ToolTip = p.ProductName
        lnkName.ToolTip = p.ProductName
        lnkThumb.ToolTip = p.ProductName



        If Not IsNothing(p.BelongsTo) Then
            lnkBelongsTo.Text = p.BelongsToName & " (" & p.BelongsTo.Contents & ")"
            lnkBelongsTo.NavigateUrl = CSitemap.Decide(p.BelongsTo)

            If litDescription.Text.Trim.Length = 0 Then
                litDescription.Text = Server.HtmlEncode(p.BelongsTo.ProductDescription).Replace(vbCrLf, "<br>")
            End If
        End If


    End Sub


#Region "User Controls"
    Private Shared Function UCContent(ByVal target As Control) As UCContent
        Dim ctrl As Control = target.Page.LoadControl(CSitemap.Store_UCContent)
        target.Controls.Add(ctrl)
        Return CType(ctrl, UCContent)
    End Function
#End Region

End Class